//
//  HZForumLeftBarItems.m
//  Expert
//
//  Created by 刘华舟 on 15/4/8.
//  Copyright (c) 2015年 BLUEBLACK. All rights reserved.
//

#import "HZForumLeftBarItems.h"
#import "HZImageSourceConstant.h"
#import "HZGlobleConstant.h"

@interface HZForumLeftBarItems()

@property (strong, nonatomic) UIImageView *backImageView;

@end

@implementation HZForumLeftBarItems

- (instancetype)initWithFrame:(CGRect)frame{
    frame = CGRectOf([self.ufo fx:UB_LEFT fy:UB_TOP], [self.ubo uw:180 uh:80]);
    if (self = [super initWithFrame:frame]) {
        self.backImageView = [[UIImageView alloc] initWithFrame:CGRectOf([self.ufo fx:UB_LEFT ux:-10 fy:UB_TOP],
                                                                         [self.ubo uw:40 fh:UB_HEIGHT])];
        [self.backImageView setImage:[UIImage imageNamed:kImageArrowLeft]];
        self.backImageView.contentMode = UIViewContentModeLeft;
        [self addSubview:self.backImageView];
        
        self.titleNameLabel = [[UILabel alloc] initWithFrame:CGRectOf([self.backImageView.ufo fx:UB_RIGHT fy:UB_TOP],
                                                                      [self.ubo uw:140 fh:UB_HEIGHT])];
        [self.titleNameLabel setBackgroundColor:HZ_CLEAR_COLOR];
        self.titleNameLabel.text = @"";
        self.titleNameLabel.textAlignment = NSTextAlignmentLeft;
        self.titleNameLabel.font = HZFontSize14;
        self.titleNameLabel.textColor = HZ_FORUM_THEME_GREEN_COLOR;
        
        [self addSubview:self.titleNameLabel];
        
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(backOnTap)];
        [self addGestureRecognizer:tapGesture];
    }
    return self;
}

- (void)backOnTap{
    if(self.delegate && [self.delegate respondsToSelector:@selector(backForumWith:)]){
        [self.delegate backForumWith:self];
    }
}

@end
